package client;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class RegisterPanel extends JPanel implements ActionListener{
	
	private JTextField user;
	private JTextField e;
	private JTextField name;
	private JTextField lastName;
	private JPasswordField pwd;

	public RegisterPanel(Client client) {
		setLayout(new BorderLayout());
		JPanel register = new JPanel(new GridLayout(7,2));
		JLabel userName = new JLabel("Username", JLabel.CENTER);
		user = new JTextField();
		JLabel password = new JLabel("Password", JLabel.CENTER);
		pwd = new JPasswordField();
		JLabel email = new JLabel("E-mail", JLabel.CENTER);
		e = new JPasswordField();
		JLabel n = new JLabel("First name", JLabel.CENTER);
		name = new JTextField();
		JLabel l = new JLabel("Last name", JLabel.CENTER);
		lastName = new JTextField();
		register.add(n);
		register.add(name);
		register.add(l);
		register.add(lastName);
		register.add(userName);
		register.add(user);
		register.add(password);
		register.add(pwd);
		register.add(email);
		register.add(e);
		JButton loginButton = new JButton("Register");
		loginButton.addActionListener(this);
		add(register, BorderLayout.NORTH);
		add(loginButton, BorderLayout.SOUTH);
		Dimension d = new Dimension(200,160);
		setSize(d);
		setPreferredSize(d);
		setLocation(client.getWidth()/2-this.getWidth()/2, 0);
		updateUI();
	}

	public void actionPerformed(ActionEvent arg0) {
		System.out.println("REGISTERED USER!");
		Client.c.login();
	}

}
